package com.aicoq.example.stock.controller;

import com.aicoq.example.stock.domain.AnalysisStockRequest;
import com.aicoq.example.stock.domain.SyncCategoryRelRequest;
import com.aicoq.example.stock.service.AnalysisStockService;
import com.aicoq.example.stock.service.StockCategoryRelService;
import com.aicoq.example.stock.service.SyncStockCategoryService;
import com.aicoq.example.stock.service.SyncStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class IndexController {

    @Autowired
    private SyncStockService stockService;
    @Autowired
    private AnalysisStockService analysisStockService;
    @Autowired
    private SyncStockCategoryService syncStockCategoryService;
    @Autowired
    private StockCategoryRelService stockCategoryRelService;

    @PostMapping("/syncStock")
    public String syncStock(@RequestBody List<String> markets) {
        stockService.syncStock(markets);
        return "OK";
    }

    @PostMapping("/analysisStock")
    public String analysisStock(@RequestBody AnalysisStockRequest request) {
        analysisStockService.analysisStock(request.getOccurDate());
        return "OK";
    }

    @PostMapping("/syncCategory")
    public String syncCategory() {
        syncStockCategoryService.syncCategory();
        return "OK";
    }

    @PostMapping("/syncCategoryRel")
    public String syncCategoryRel(@RequestBody SyncCategoryRelRequest request) {
        stockCategoryRelService.syncCategoryRel(request);
        return "OK";
    }
}
